// Tierless
// Copyright © 2010 Alphora
// This file is licensed under a modified BSD-license (see tierless_license.txt).
using System.IO;

namespace Tierless.Infrastructure
{
	public static class StreamUtility
	{
		public const int CDefaultBufferSize = 4096;

		public static void CopyStream(Stream ASource, Stream ATarget)
		{
			CopyStream(ASource, ATarget, CDefaultBufferSize);
		}
		
		public static void CopyStream(Stream ASource, Stream ATarget, int ABufferSize)
		{
			var LBuffer = new byte[ABufferSize];
			int LCount;
			while ((LCount = ASource.Read(LBuffer, 0, ABufferSize)) > 0)
				ATarget.Write(LBuffer, 0, LCount);
		}
	}
}
